package com.bys.managercolok;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;

public class RemindAlarmReceiver extends BroadcastReceiver {

    @Override
    public void onReceive(Context context, Intent intent) {
        String msg = intent.getStringExtra("msg");
        long intervalMillis = intent.getLongExtra("intervalMillis", 0);
        if(intervalMillis !=  0)
            AlarmManagerUtil.setAlarmTime(context,System.currentTimeMillis()+ intervalMillis,intent);
        int flag = intent.getIntExtra("soundOrVibrator",0);
        Intent clockIntent = new Intent(context,ClockAlarmActivity.class);
        clockIntent.putExtra("msg",msg);
        clockIntent.putExtra("flag",flag);
//        若须要创建的Activity已经处于栈中时，此时不会创建新的Activity，而是将存在栈中的Activity上面的其他Activity所有销毁，使它成为栈顶。
        clockIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        context.startActivity(clockIntent);
    }
}
